package reflect;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.Scanner;
public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        //Class cls=String.class;
        //Class cls=ArrayList.class;
        //Class cls= FileInputStream.class;
       // Class cls=Class.forName("java.lang.String");
        //Class cls=Class.forName("java.io.FileInputStream");

        Scanner scan=new Scanner(System.in);
        System.out.println("请输入一个类名：");
        String className=scan.nextLine();
        Class cls=Class.forName(className);

        String name=cls.getName();
        System.out.println(name);

        name=cls.getSimpleName();
        System.out.println(name);

        Package pkg=cls.getPackage();
        System.out.println(pkg.getName());

        Method[] methods=cls.getMethods();
        System.out.println("共"+methods.length+"个方法");
        for(Method m:methods){
            System.out.println(m.getName());
        }
    }
}
